How to detect that a process is started using C# code[windows service]
Posted
by infant programmer
on Stack Overflow
See other posts from Stack Overflow
or by infant programmer
Published on 2010-03-18T10:26:38Z
Indexed on
2010/03/18
11:01 UTC
Read the original article
Hit count: 134
windows-services
|c#
I am trying to design a windows-service which monitors a process namely "Gtalk", if the process is started then, the browser Internet-explorer (process iexplore) should be closed. This should happen only when the process "Gtalk" is started, [not when running]
The code I have written and implemented, doesn't allow to open IExplore when Gtalk is running. That is certainly what not I am trying for. The process Gtalk should close browser only at its start-up, After the process is started, it should allow to open IExplore.
Is it possible with Windows service or is it must be the part of Gtalk process itself?
This is my code:
while (true)
{
if (Process.GetProcessesByName("Gtalk").Length > 0)
{
foreach (Process prc in Process.GetProcessesByName("IExplore"))
{
prc.Kill();
}
}
}
© Stack Overflow or respective owner